#include "FreeRTOS.h"
#include "task.h"

#include "led.h"


#define   LED2_PORT  GPIOD
#define   LED2_PIN   GPIO_PIN_4

#define   LED3_PORT  GPIOD
#define   LED3_PIN   GPIO_PIN_7

#define   LED_ON    GPIO_PIN_RESET
#define   LED_OFF   GPIO_PIN_SET



void vTaskLedFlash(void *pvParameters) {
	while(1) {
		LedOn(1);
		vTaskDelay(500);
		LedOff(1);
		vTaskDelay(500);
	}
}


// @param: 0 = Led2 & Led3, 1 = Led2, 2 = Led3
void LedOn(uint8_t nLed) {
	switch(nLed) {
		case 0:
			HAL_GPIO_WritePin(LED2_PORT, LED2_PIN, LED_ON);
			HAL_GPIO_WritePin(LED3_PORT, LED3_PIN, LED_ON);
			break;
		case 1:
			HAL_GPIO_WritePin(LED2_PORT, LED2_PIN, LED_ON);
			break;
		case 2:
			HAL_GPIO_WritePin(LED3_PORT, LED3_PIN, LED_ON);
			break;
		default:
			break;
	}
}


// @param: 0 = Led2 & Led3, 1 = Led2, 2 = Led3
void LedOff(uint8_t nLed) {
	switch(nLed) {
		case 0:
			HAL_GPIO_WritePin(LED2_PORT, LED2_PIN, LED_OFF);
			HAL_GPIO_WritePin(LED3_PORT, LED3_PIN, LED_OFF);
			break;
		case 1:
			HAL_GPIO_WritePin(LED2_PORT, LED2_PIN, LED_OFF);
			break;
		case 2:
			HAL_GPIO_WritePin(LED3_PORT, LED3_PIN, LED_OFF);
			break;
		default:
			break;
	}
}


// @param: 0 = Led2 & Led3, 1 = Led2, 2 = Led3
void LedToggle(uint8_t nLed) {
	switch(nLed) {
		case 0:
			HAL_GPIO_TogglePin(LED2_PORT, LED2_PIN);
			HAL_GPIO_TogglePin(LED3_PORT, LED3_PIN);
			break;
		case 1:
			HAL_GPIO_TogglePin(LED2_PORT, LED2_PIN);
			break;
		case 2:
			HAL_GPIO_TogglePin(LED3_PORT, LED3_PIN);
			break;
		default:
			break;
	}
}

